class Solution:
    """利用and短路停止递归
    """

    
    def __init__(self):
        """
        Instance Initialize.
        """
        
        self._res = 0

    def sumNums(self, n: int) -> int:
        """每次递归，向_res加一个数"""
        n > 1 and self.sumNums(n-1)
        self._res += n
        return self._res

if __name__ == '__main__':
    c = Solution()
    print(c.sumNums(2))